package greate.project.event1;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.lang.NonNull;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class EmailService1 implements ApplicationListener<UserRegisterEvent1> { // <1>

    @Override
    @Async("asyncExecutorService")// <3>
    public void onApplicationEvent(@NonNull UserRegisterEvent1 event) { // <2>
        System.out.println("email: " + Thread.currentThread().getName());
        log.info("[onApplicationEvent][给用户({}) 发送邮件]", event.getUsername());
    }
}